package spring_root.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import spring_root.po.User;

@Controller
public class loginController {
	
	@RequestMapping(value = "/login",method = {RequestMethod.POST})
	@ResponseBody
	public String login(User user,HttpServletRequest request) {
		
		System.out.println(user.getUsername()+"  "+user.getPassword());
		
		boolean b = (user.getUsername()!=null && !"".equals(user.getUsername())) && "123456".equals(user.getPassword());
		//任意用户名与123456 为登录账号密码
		if(b) {
			request.getSession().setAttribute("loginUser", user);
			return "success";
		}else {
			return "error";
		}
	}
	
	@RequestMapping(value="/showPerson", method = {RequestMethod.GET})
	public String getshowPersonPage() {
		
		return "/html/showPerson.html";
	}
}
